import { pubRequire } from '@utils/public'
const baseUrl = '/tags/categories'
//获取列表
export function getCategoriesList(obj, callbBack, errBack) {
  return pubRequire('get', `${baseUrl}`, obj, callbBack, errBack)
}
//批量删除
export function multipleDel(obj, callBack, errBack) {
  return pubRequire('delete', `${baseUrl}`, obj, callBack, errBack)
}
//单个删除
export function singleDel(id, callBack, errBack) {
  return pubRequire('delete', `${baseUrl}/${id}`, '', callBack, errBack)
}
//获取标签分类下的用户数量
export function getUserCount(id, callBack, errBack) {
  return pubRequire('get', `${baseUrl}/${id}/count`, '', callBack, errBack)
}
//改变状态,启用/停用
export function changeStatus(id, status, callBack, errBack) {
  let url = `${baseUrl}/${id}/`
  let str = status ? 'enable' : 'disable'
  url += str
  return pubRequire('put', url, '', callBack, errBack)
}
//新增标签分类
export function addCategories(obj, callBack, errBack) {
  return pubRequire('post', `${baseUrl}`, obj, callBack, errBack)
}
//标签分类列表
export function tagCategoryNames(callBack, errBack) {
  return getTagList(false, callBack, errBack)
}
//导入接口
export function importUrl() {
  return `${baseUrl}/import`
}
//下载模板接口
export function downUrl() {
  return `${baseUrl}/download`
}
//获取标签分类下的标签列表
export function getTagList(id, callBack, errBack) {
  let obj
  if (id) {
    obj = {
      categoriesId: id
    }
  } else {
    obj = ''
  }
  return pubRequire('get', `${baseUrl}/options`, obj, callBack, errBack)
}
